/*
 *  Outside.cpp
 *  lab3
 *
 *  Created by Fredrik Gustafsson on 11/17/10.
 *  Copyright 2010 Kungliga Tekniska Högskolan. All rights reserved.
 *
 */

#include "Outside.h"
#include "Monster.h"

using namespace wok2;

#define MONSTER_NAME "dracula"

Outside::Outside(std::string n_name, std::string n_description) : Environment(8) {
	name = n_name;
	description = n_description;
}

Outside::~Outside() {
	Actor* random_monster = this->pop_actor(MONSTER_NAME);
	if (random_monster != NULL) {
#ifdef DEBUG_DEALLOC
		std::cout << "\t*DBG* Deallocating:" << random_monster->name << std::endl;
#endif
		delete random_monster;
	}
}

std::string Outside::type() const {
	return "outside";
}

void Outside::randomize_monster() {
	bool dracula_appears = (rand()%4 == 0);
	if (dracula_appears) {
		Actor* random_monster;
		random_monster = this->pop_actor(MONSTER_NAME);
		if (random_monster == NULL) {
			random_monster = new Monster(MONSTER_NAME);
#ifdef DEBUG_ALLOC
			std::cout << "*DBG* Allocated:" << random_monster->name << std::endl;
#endif
			std::cout<< "Out of the mist, the king of death appears!"<< std::endl;
		}
		this->push_actor(random_monster);
		
	}		
}

void Outside::print_room(){
	std::cout << description << std::endl;
	randomize_monster();
	print_actors();
	print_items();
	std::cout << "Exits: " ;
	print_directions();
}